package com.shangqing.web.controller.system;


import com.shangqing.common.core.domain.AjaxResult;
import com.shangqing.system.domain.caoyuan.Caoyuan;
import com.shangqing.system.domain.caoyuan.vo.*;
import com.shangqing.system.service.CaoyuanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

/**
 * 草原火灾相关接口
 */
@Api(tags = "火灾", description = "草原火灾相关接口", position = 1)
@RestController
@RequestMapping("/caoyuan")
public class CaoyuanController {
    @Autowired
    private CaoyuanService caoyuanService;

    @ApiOperation(value = "灾情信息", notes = "注意参数必填", position = 11)
    @GetMapping("/list")
    public AjaxResult getInfo() {
        List<Caoyuan> caoyuans = caoyuanService.getinfo();
        if (caoyuans.isEmpty()) {
            return AjaxResult.error(404, "没有找到");
        } else {
            return AjaxResult.success("成功了", caoyuans);
        }
    }


    @ApiOperation(value = "全区森林草原火灾灾情种类统计", notes = "注意参数必填", position = 11)
    @GetMapping("/species")
    public AjaxResult getspecies() {
        List<SpeciesVo> speciesVo = caoyuanService.getspecies();
        if (speciesVo.isEmpty()) {
            return AjaxResult.success("你还没有数据");
        } else {
            return AjaxResult.success("成功了", speciesVo);
        }
    }

    @ApiOperation(value = "按照月查", notes = "注意参数必填", position = 11)
    @GetMapping("/alert")
    public AjaxResult getalert() {
        List<AlertVo> alertVoList = caoyuanService.getalert();
        if (alertVoList.isEmpty()) {
            return AjaxResult.success("你还没有数据");
        } else {
            return AjaxResult.success("成功了", alertVoList);
        }
    }

    @ApiOperation(value = "区地质灾害发生占比", notes = "注意参数必填", position = 11)
    @GetMapping("/city")
    public AjaxResult getcity() {
     List<CityVo> list=caoyuanService.getcity();
        if (list.isEmpty()) {
            return AjaxResult.success("你还没有数据");
        } else {
            return AjaxResult.success("成功了", list);
        }
    }
    @ApiOperation(value = "各区灾情统计", notes = "注意参数必填", position = 11)
    @GetMapping("/cityandspecies")
    public AjaxResult getcityandspecies() {
        List<Cityandalert> list=caoyuanService.getcityandspecies();
        if (list.isEmpty()) {
            return AjaxResult.success("你还没有数据");
        } else {
            return AjaxResult.success("成功了", list);
        }
    }

    @ApiOperation(value = "地区植被分布信息", notes = "注意参数必填", position = 11)
    @GetMapping("/cityandvegetation")
    public AjaxResult getcityandvegetation() {
        List<VegetationVo> list=caoyuanService.getcityandvegetation();
        if (list.isEmpty()) {
            return AjaxResult.success("你还没有数据");
        } else {
            return AjaxResult.success("成功了", list);
        }
    }

}
